package be.vdab;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import be.vdab.services.NamenService;

public class Main {

	/**
	 * @param args
	 */
	// Ge wilt toch versie 3 van Spring gebruiken?
	// ja...doe ik da nie? uw Class zit blijkbaar niet in de spring core
	public static void main(String[] args) {
		System.out.println("Spring container configuratie begint.");
		ApplicationContext context = new ClassPathXmlApplicationContext(
				"spring.xml");
		System.out.println("Spring container configuratie gedaan.");

		ClassA objectA = context.getBean("classA", ClassA.class);
		// InterfaceA objectA = context.getBean(InterfaceA.class);
		ClassB objectB = context.getBean("classB", ClassB.class);

		System.out.println(objectA.getBoodschap());
		System.out.println(objectA.getWebMasterEMailAdres());
		System.out.println(objectA.getWebsiteGestart());
		System.out.println(objectB.getBoodschap());

		System.out.println(objectA.getTelefoonNrHelpDesk());
		System.out.println(objectA.getAantalPogingenUpdateKlant());
		try {
			System.out.println(objectA.getUrlKoersenVreemdeMuntenTOVEuro()
					.getHost());
		} catch (Exception ex) { // getHost() kan exception werpen
			ex.printStackTrace();
		}
		System.out.println(objectA.getDefaultTaalEnLandVanDeApplicatie()
				.getDisplayName());
		System.out.print("Importbestand bestaat");
		if (!objectA.getBestandMetTeImporterenData().exists()) {
			System.out.print(" niet");
		}
		System.out.println();
		System.out.println(objectA.getMaxTemperatuurMotor());
		System.out.println(objectA.getStandaardBladRichtingInPrinter());

		System.out.println(objectB.getTelefoonNrHelpDesk());
		System.out.println(objectB.getAantalPogingenUpdateKlant());

		HelpdeskMedewerkers medewerkers = context
				.getBean(HelpdeskMedewerkers.class);
		System.out.println(medewerkers);
		Scanner scanner = new Scanner(System.in);
		System.out.print("Naam: ");
		// String naam = scanner.nextLine();
		// String telefoonNr = medewerkers.getInternTelefoonNr(naam);
		// System.out.println(telefoonNr == null ? "Niet gevonden" :
		// telefoonNr);

		Teller teller1 = context.getBean("teller1", Teller.class);
		System.out.println(teller1.getTeller());
		System.out.println(teller1.getTeller());
		teller1.verhoogTeller();
		System.out.println(teller1.getTeller());
		System.out
				.println(context.getBean("teller1", Teller.class).getTeller());
		System.out
				.println(context.getBean("teller2", Teller.class).getTeller());
		Teller teller = new Teller(1);
		System.out.println(teller.getTeller());

		List<String> namen = new ArrayList<String>();

		System.out
				.println("Tik de namen, gescheiden door Enter. Tik stop na de laatste naam");
		for (String naam; !"stop".equals(naam = scanner.nextLine());) {
			namen.add(naam);
		}
		NamenService namenService = context.getBean(NamenService.class);
		namenService.opslaan(namen);
	}
}
